package org.goj.practice.controller;

import cn.hutool.core.lang.Assert;
import org.goj.common.model.Result;
import org.goj.practice.service.ContestProblemService;
import org.goj.practice.vo.ContestProblemVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 竞赛题目 前端控制器
 * </p>
 *
 * @author CK
 * @since 2020-12-02
 */
@RestController
@RequestMapping("/contest-problem")
public class ContestProblemController {

    @Autowired
    private ContestProblemService contestProblemService;

    /**
     * 查询竞赛题目列表
     *
     * @param contestId 竞赛ID
     * @param userId    用户ID
     * @return Result<List < ContestProblemVO>>
     * @author CK
     * @date 2021/4/22 19:38
     */
    @GetMapping("/listContestProblem")
    public Result<List<ContestProblemVO>> listContestProblem(@RequestParam(value = "contestId") Integer contestId, @RequestParam(value = "userId") Integer userId) {
        List<ContestProblemVO> list = contestProblemService.listContestProblem(contestId, userId);
        Assert.isTrue(list.size() > 0, "查询竞赛题目列表失败");
        return Result.succeed("查询竞赛题目列表成功", list);
    }

}

